{
 "cells": [
  {
   "cell_type": "code",
   "metadata": {
    "jupyter": {
     "is_executing": true
    }
   },
   "source": [
    "import numpy as np \n",
    "import pandas as pd \n",
    "import warnings\n",
    "warnings.filterwarnings('ignore')\n",
    "import os \n",
    "os.chdir('F:/安装包/PPD-First-Round-Data-Updated/PPD-First-Round-Data-Update/')"
   ],
   "outputs": [],
   "execution_count": null
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "f_train1 = pd.read_csv('Training Set/PPD_Training_Master_GBK_3_1_Training_Set.csv',encoding='gbk')\n",
    "f_train2 = pd.read_csv('Training Set/PPD_Userupdate_Info_3_1_Training_Set.csv',encoding='gbk')\n",
    "f_train3 = pd.read_csv('Training Set/PPD_LogInfo_3_1_Training_Set.csv',encoding='gbk')\n",
    "f_test1 = pd.read_csv('Test Set/PPD_Master_GBK_2_Test_Set.csv',encoding='gb18030')\n",
    "f_test2 = pd.read_csv('Test Set/PPD_Userupdate_Info_2_Test_Set.csv',encoding='gbk')\n",
    "f_test3 = pd.read_csv('Test Set/PPD_LogInfo_2_Test_Set.csv',encoding='gbk')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 训练集和测试集合并\n",
    "f_train1['sample_status'] = 'train'\n",
    "f_test1['sample_status'] = 'test'\n",
    "df1 = pd.concat([f_train1,f_test1],axis=0).reset_index(drop=True)\n",
    "df2 = pd.concat([f_train2,f_test2],axis=0).reset_index(drop=True)\n",
    "df3 = pd.concat([f_train3,f_test3],axis=0).reset_index(drop=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Education_Info1</th>\n",
       "      <th>Education_Info2</th>\n",
       "      <th>Education_Info3</th>\n",
       "      <th>Education_Info4</th>\n",
       "      <th>Education_Info5</th>\n",
       "      <th>Education_Info6</th>\n",
       "      <th>Education_Info7</th>\n",
       "      <th>Education_Info8</th>\n",
       "      <th>Idx</th>\n",
       "      <th>ListingInfo</th>\n",
       "      <th>...</th>\n",
       "      <th>WeblogInfo_55</th>\n",
       "      <th>WeblogInfo_56</th>\n",
       "      <th>WeblogInfo_57</th>\n",
       "      <th>WeblogInfo_58</th>\n",
       "      <th>WeblogInfo_6</th>\n",
       "      <th>WeblogInfo_7</th>\n",
       "      <th>WeblogInfo_8</th>\n",
       "      <th>WeblogInfo_9</th>\n",
       "      <th>sample_status</th>\n",
       "      <th>target</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>E</td>\n",
       "      <td>E</td>\n",
       "      <td>E</td>\n",
       "      <td>0</td>\n",
       "      <td>E</td>\n",
       "      <td>E</td>\n",
       "      <td>E</td>\n",
       "      <td>10001</td>\n",
       "      <td>2014/3/5</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>14</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>train</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0</td>\n",
       "      <td>E</td>\n",
       "      <td>E</td>\n",
       "      <td>E</td>\n",
       "      <td>0</td>\n",
       "      <td>E</td>\n",
       "      <td>E</td>\n",
       "      <td>E</td>\n",
       "      <td>10002</td>\n",
       "      <td>2014/2/26</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>14</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>train</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0</td>\n",
       "      <td>E</td>\n",
       "      <td>E</td>\n",
       "      <td>E</td>\n",
       "      <td>0</td>\n",
       "      <td>E</td>\n",
       "      <td>E</td>\n",
       "      <td>E</td>\n",
       "      <td>10003</td>\n",
       "      <td>2014/2/28</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>9</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>train</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0</td>\n",
       "      <td>E</td>\n",
       "      <td>E</td>\n",
       "      <td>E</td>\n",
       "      <td>0</td>\n",
       "      <td>E</td>\n",
       "      <td>E</td>\n",
       "      <td>E</td>\n",
       "      <td>10006</td>\n",
       "      <td>2014/2/25</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>train</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0</td>\n",
       "      <td>E</td>\n",
       "      <td>E</td>\n",
       "      <td>E</td>\n",
       "      <td>0</td>\n",
       "      <td>E</td>\n",
       "      <td>E</td>\n",
       "      <td>E</td>\n",
       "      <td>10007</td>\n",
       "      <td>2014/2/27</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>train</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 229 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   Education_Info1 Education_Info2 Education_Info3 Education_Info4  \\\n",
       "0                0               E               E               E   \n",
       "1                0               E               E               E   \n",
       "2                0               E               E               E   \n",
       "3                0               E               E               E   \n",
       "4                0               E               E               E   \n",
       "\n",
       "   Education_Info5 Education_Info6 Education_Info7 Education_Info8    Idx  \\\n",
       "0                0               E               E               E  10001   \n",
       "1                0               E               E               E  10002   \n",
       "2                0               E               E               E  10003   \n",
       "3                0               E               E               E  10006   \n",
       "4                0               E               E               E  10007   \n",
       "\n",
       "  ListingInfo  ...  WeblogInfo_55  WeblogInfo_56  WeblogInfo_57  \\\n",
       "0    2014/3/5  ...              0              0              0   \n",
       "1   2014/2/26  ...              0              0              0   \n",
       "2   2014/2/28  ...              0              0              0   \n",
       "3   2014/2/25  ...              0              0              0   \n",
       "4   2014/2/27  ...              0              0              0   \n",
       "\n",
       "   WeblogInfo_58  WeblogInfo_6  WeblogInfo_7  WeblogInfo_8  WeblogInfo_9  \\\n",
       "0              0           1.0            14             0             0   \n",
       "1              0           1.0            14             0             0   \n",
       "2              0           2.0             9             3             0   \n",
       "3              0           NaN             2             0             0   \n",
       "4              0           1.0             3             0             0   \n",
       "\n",
       "   sample_status  target  \n",
       "0          train     0.0  \n",
       "1          train     0.0  \n",
       "2          train     0.0  \n",
       "3          train     0.0  \n",
       "4          train     0.0  \n",
       "\n",
       "[5 rows x 229 columns]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df1.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 保存数据至本地\n",
    "df1.to_csv('./data_input1.csv',encoding='gb18030',index=False)\n",
    "df2.to_csv('./data_input2.csv',encoding='gb18030',index=False)\n",
    "df3.to_csv('./data_input3.csv',encoding='gb18030',index=False)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.1"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
